import { defHttp } from '@/utils/http/axios';

enum Api {
  GetGroup = '/agent/view/index',
  GetGroupAcceptOrder = '/agent/view/acceptOrder',
  GetGroupGrabOrder = '/agent/view/grabOrder',
  AddAgent = '/agent/newAgent/add',
  EditAgent = '/agent/newAgent/edit',
  TeamBill = '/agent/teamBill/index',
  GetRate = '/agent/view/getRateCode',
  EditRate = '/agent/view/editRateCode',
  EditRatePay = '/agent/view/editRateCodePayment',
  GetRandom = '/agent/view/RandomRand',
}

export function getGroupApi(params: {
  page: number;
  pageSize: number;
  keyword?: string;
  order?: string;
}) {
  return defHttp.post<any>({
    url: Api.GetGroup + `?page=${params.page}&limit=${params.pageSize}`,
    params,
  });
}

export function GetGroupAcceptOrderApi(params: { id: number }) {
  return defHttp.post<any>({
    url: Api.GetGroupAcceptOrder,
    params,
  });
}

export function GetGroupGrabOrderApi(params: { id: number }) {
  return defHttp.post<any>({
    url: Api.GetGroupGrabOrder,
    params,
  });
}

export function AddAgentApi(params: any) {
  return defHttp.post<any>({
    url: Api.AddAgent,
    params,
  });
}

export function EditAgentApi(params: any) {
  return defHttp.post<any>({
    url: Api.EditAgent,
    params,
  });
}

export function GetTeamBillApi(params: any) {
  return defHttp.post<any>({
    url: Api.TeamBill + `?page=${params.page}&limit=${params.pageSize}`,
    params,
  });
}

export function GetRateApi(params: { id: string }) {
  return defHttp.post<any>({
    url: Api.GetRate,
    params,
  });
}

export function EditRateApi(params: any) {
  return defHttp.post<any>({
    url: Api.EditRate,
    params,
  });
}

export function EditRatePayApi(params: any) {
  return defHttp.post<any>({
    url: Api.EditRatePay,
    params,
  });
}

export function GetRandomApi(type: number) {
  return defHttp.post<any>({
    url: Api.GetRandom,
    params: { type },
  });
}
